home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////
- // Harrow Software 1996
- // Bitmap examples
-
- ///////////////////////////
- // (1) - Floating point arrays
-
- // A new floating point array with 4x4 elements can be allocated
-
- my_array = new float[4][4]
-
- // These element will be assigned random values between 0 and 100
-
- for x,y = 0,0 to 3,3
- my_array[x][y] = rnd 100
-
- // Get the size of the array
-
- size_of_1st_dimension = my_array(0)
- size_of_2nd_dimension = my_array(1)
-
- for x,y = 0,0 to size_of_1st_dimension-1, size_of_2nd_dimension-1
- message my_array[x][y]
-
- ///////////////////////////
- // (2) - Byte Arrays
-
- // This new byte array will be allocated with 256 red, green and
- // blue values
-
- my_palette = new byte[256][3]
-
- // This palette can then be filled with a scale of grey colors
-
- for n = 0 to 255
- my_palette[n][0] = n,n,n
-
- // Strings are stored as byte arrays. This assignment will
- // allocate a byte array large enough to store the length of the
- // string plus one for the terminating zero.
-
- $my_string = "This is a string"
-
- // The ansi values of each character in the string can be
- // shown. The ansi value of 'A' is 65.
-
- n = 0
- while my_string[n]
- message my_string[n], " = '", strchr my_string[n], "'"
- n++
-
- ///////////////////////////
- // (3) - Text files
-
- // A text file can be loaded from disk into a byte array and
- // assigned to a handle. A text file can also be saved to disk
-
- load "example.txt" byte my_text
- save "example.txt" byte my_text
-
- // You can search the contents of a text array for any
- // matching string. The search will start from the given
- // position in the array
-
- my_pos = 0
- my_pos = parse my_text[my_pos] for "some string"
- if my_pos == ERROR
- message "String not found"
-
- // A text array can be broken down into words and numbers. Each
- // word and number in this file will be displayed in the result
- // window
-
- my_pos = 0
- while my_pos != ERROR
- my_pos = parse my_text[my_pos] to $my_string
- if my_pos != ERROR then message $my_string
- message "End of text"
-
-
-
-
-
-